import Vue from 'vue'
import VueRouter from 'vue-router'
import NProgress from 'nprogress' 
import 'nprogress/nprogress.css'// nprogress样式文件

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'index',
    component: () => import(/* webpackChunkName: "about" */ '../views/index/index.vue')
  },
  {
    path: '/index',
    name: 'index',
    component: () => import(/* webpackChunkName: "about" */ '../views/index/index.vue')
  },
  {
    path: '/left',
    name: 'left',
    component: () => import(/* webpackChunkName: "about" */ '../components/left/index.vue')
  },
  {
    path: '/top',
    name: 'top',
    component: () => import(/* webpackChunkName: "about" */ '../components/top/index.vue')
  },
  {
    path: '/head',
    name: 'head',
    component: () => import(/* webpackChunkName: "about" */ '../components/head/index.vue')
  },
  {
    path: '/foot',
    name: 'foot',
    component: () => import(/* webpackChunkName: "about" */ '../components/foot/index.vue')
  },
  {
    path: '/load',
    name: 'load',
    component: () => import(/* webpackChunkName: "about" */ '../views/load/index.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "about" */ '../views/login/index.vue')
  },
  {
    path: '/loginlog',
    name: 'loginlog',
    component: () => import(/* webpackChunkName: "about" */ '../views/loginlog/index.vue')
  },
  {
    path: '/file-resources',
    name: 'file-resources',
    component: () => import(/* webpackChunkName: "file-resources" */ '../views/file-resources/index.vue')
  },
  {
    path: '/database-resources',
    name: 'database-resources',
    component: () => import(/* webpackChunkName: "database-resources" */ '../views/database-resources/index.vue')
  },
  {
    path: '/other-resources',
    name: 'other-resources',
    component: () => import(/* webpackChunkName: "other-resources" */ '../views/other-resources/index.vue')
  },
  {
    path: '/user-management',
    name: 'user-management',
    component: () => import(/* webpackChunkName: "user-management" */ '../views/user-management/index.vue')
  },
  {
    path: '/role-management',
    name: 'role-management',
    component: () => import(/* webpackChunkName: "role-management" */ '../views/role-management/index.vue')
  },
  {
    path: '/menu-management',
    name: 'menu-management',
    component: () => import(/* webpackChunkName: "menu-management" */ '../views/menu-management/index.vue')
  },
  {
    path: '/department-management',
    name: 'department-management',
    component: () => import(/* webpackChunkName: "department-management" */ '../views/department-management/index.vue')
  },
  {
    path: '/job-management',
    name: 'job-management',
    component: () => import(/* webpackChunkName: "job-management" */ '../views/job-management/index.vue')
  },
  {
    path: '/dictionary-management',
    name: 'dictionary-management',
    component: () => import(/* webpackChunkName: "dictionary-management" */ '../views/dictionary-management/index.vue')
  },
  {
    path: '/code-generation',
    name: 'code-generation',
    component: () => import(/* webpackChunkName: "code-generation" */ '../views/code-generation/index.vue')
  },
  {
    path: '/log-management',
    name: 'log-management',
    component: () => import(/* webpackChunkName: "log-management" */ '../views/log-management/index.vue')
  },
  {
    path: '/operation-log',
    name: 'operation-log',
    component: () => import(/* webpackChunkName: "operation-log" */ '../views/operation-log/index.vue')
  },
  {
    path: '/online-task',
    name: 'online-task',
    component: () => import(/* webpackChunkName: "online-task" */ '../views/online-task/index.vue')
  },
  {
    path: '/scheduled-task',
    name: 'scheduled-task',
    component: () => import(/* webpackChunkName: "scheduled-task" */ '../views/scheduled-task/index.vue')
  },
  {
    path: '/service-monitoring',
    name: 'service-monitoring',
    component: () => import(/* webpackChunkName: "service-monitoring" */ '../views/service-monitoring/index.vue')
  },
  {
    path: '/data-monitoring',
    name: 'data-monitoring',
    component: () => import(/* webpackChunkName: "data-monitoring" */ '../views/data-monitoring/index.vue')
  },
  {
    path: '/cache-monitoring',
    name: 'cache-monitoring',
    component: () => import(/* webpackChunkName: "cache-monitoring" */ '../views/cache-monitoring/index.vue')
  },
  {
    path: '/system-monitoring',
    name: 'system-monitoring',
    component: () => import(/* webpackChunkName: "system-monitoring" */ '../views/system-monitoring/index.vue')
  },
  {
    path: '/person',
    name: 'person',
    component: () => import(/* webpackChunkName: "person" */ '../views/person/index.vue')
  }
  
]

const router = new VueRouter({
  mode: 'history', //去除路由中的 #
  routes
})

//当路由开始跳转时 路由进度条
router.beforeEach((to, from , next) => {
  // 开启进度条
  NProgress.start();
  next();
});
//当路由跳转结束后
router.afterEach(() => {  
  // 关闭进度条
  NProgress.done()
})
export default router
